﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using ADOX;
using MdbWatch;

public partial class Mdbw_DBTableList : Page
{
    public int fid = 0;
    //List<Model.Boards> list = BLL.Boards.instance.GetList("");
    protected void Page_Load(object sender, EventArgs e)
    {
        litercopyright.Text = "版权所有,试用版请勿用于商业用途!38809972@qq.com";
        BindData();
    }

    private void BindData()
    {
        DataTable dt =DbHelper.GetShemaTable();        
        gvList.DataSource = dt;
        gvList.DataBind();
    }

  
    protected void gvList_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Delete")        
        {
            string tablename = e.CommandArgument.ToString();         
            DbHelper.DeleteTable(tablename);
            BindData();
        }
    }
    protected void gvList_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {

    }
    public void UpdateTables(string conn, string tablename)
    {
        ADOX.CatalogClass cate = new CatalogClass();
        cate.ActiveConnection = DbHelper.webstr;
        cate.Tables[""].Columns["fds"].Properties["fds"].Value = "fdsf";
    }
    protected void dropSort_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (dropSort.SelectedValue != "incms")
        {
            DataTable dt = DbHelper.GetShemaTable();
            DataView dv = dt.DefaultView;
            dv.RowFilter = "table_name like '" + dropSort.SelectedValue + "%'";
            gvList.DataSource = dv;
            gvList.DataBind();
        }
        else
        {
            DataTable dt = DbHelper.GetShemaTable();
            DataView dv = dt.DefaultView;
            dv.RowFilter = "table_name not like 'Sys_%'  and table_name not like  'U_%'";
            gvList.DataSource = dv;
            gvList.DataBind();
        }
    }
    protected override void OnInit(EventArgs e)
    {
        if (!IsPostBack)
        {
            //添加访问权限的逻辑,session和server.avariable["refer"]以及主机名称.防止跨域提交表单
            if (Request.ServerVariables["HTTP_Referer"] == null || Request.ServerVariables["REMOTE_HOST"] == null || Request.ServerVariables["SERVER_NAME"] != Request.Url.Host)
            {
                Response.Write("非法访问!");
                Response.End();
                return;
            }
        }
    }
}

